<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>鲜花订购管理系统</title>
  <link rel="stylesheet" href="layui/css/layui.css">
</head>
<body>
<div class="layui-layout layui-layout-admin">
  <div class="layui-header">
    <div class="layui-logo layui-hide-xs layui-bg-black">鲜花订购后台管理</div>
    <!-- 头部区域（可配合layui 已有的水平导航） -->
    <ul class="layui-nav layui-layout-left">
      <!-- 移动端显示 -->
      <li class="layui-nav-item layui-show-xs-inline-block layui-hide-sm" lay-header-event="menuLeft">
        <i class="layui-icon layui-icon-spread-left"></i>
      </li>

<!--      <li class="layui-nav-item layui-hide-xs"><a href="">患者人员管理</a></li>-->
<!--      <li class="layui-nav-item layui-hide-xs"><a href="">nav 2</a></li>-->
<!--      <li class="layui-nav-item layui-hide-xs"><a href="">nav 3</a></li>-->
<!--      <li class="layui-nav-item">-->
<!--        <a href="javascript:;">nav groups</a>-->
<!--        <dl class="layui-nav-child">-->
<!--          <dd><a href="">menu 11</a></dd>-->
<!--          <dd><a href="">menu 22</a></dd>-->
<!--          <dd><a href="">menu 33</a></dd>-->
<!--        </dl>-->
<!--      </li>-->
    </ul>
    <ul class="layui-nav layui-layout-right">
      <li class="layui-nav-item layui-hide layui-show-md-inline-block">
        <a href="javascript:;">
          <img src="img/j.png" class="layui-nav-img">
          <span id="span">未登录</span>
        </a>
        <dl class="layui-nav-child">
          <dd><a href="javascript:;" onclick="queryAdmin()">个人信息</a></dd>
<!--          <dd><a href="">设置</a></dd>-->
          <dd><a href="/user/logout">退出</a></dd>
        </dl>
      </li>
      <li class="layui-nav-item" lay-header-event="menuRight" lay-unselect>
<!--        <a href="javascript:;">-->
<!--          <i class="layui-icon layui-icon-more-vertical"></i>-->
<!--        </a>-->
      </li>
    </ul>
  </div>

  <div class="layui-side layui-bg-black">
    <div class="layui-side-scroll">
      <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
      <ul class="layui-nav layui-nav-tree" lay-filter="test">
        <li class="layui-nav-item layui-nav-itemed">
          <a class="" href="javascript:;">用户管理</a>
          <dl class="layui-nav-child">
            <dd><a href="javascript:;" onclick="openUrl('userList.html')">用户查询</a></dd>
            <dd><a href="javascript:;" onclick="openUrl('userAdd.html')">用户添加</a></dd>
<!--            <dd><a href="javascript:;">menu 3</a></dd>-->
<!--            <dd><a href="">the links</a></dd>-->
          </dl>
        </li>
        <li class="layui-nav-item">
          <a href="javascript:;">鲜花管理</a>
          <dl class="layui-nav-child">
            <dd><a href="javascript:;" onclick="openUrl('flowerList.html')">鲜花查询</a></dd>
            <dd><a href="javascript:;" onclick="openUrl('flowerAdd.html')">鲜花添加</a></dd>
<!--            <dd><a href="">超链接</a></dd>-->
          </dl>
        </li>
<!--        <li class="layui-nav-item"><a href="javascript:;">click menu item</a></li>-->
<!--        <li class="layui-nav-item"><a href="">the links</a></li>-->
        <li class="layui-nav-item">
          <a href="javascript:;">订单管理</a>
          <dl class="layui-nav-child">
            <dd><a href="javascript:;" onclick="openUrl('orderList.html')">订单查询</a></dd>
            <dd><a href="javascript:;" onclick="openUrl('orderAdd.html')">订单添加</a></dd>
            <!--            <dd><a href="">超链接</a></dd>-->
          </dl>
        </li>
        <li class="layui-nav-item">
          <a href="javascript:;">公告管理</a>
          <dl class="layui-nav-child">
            <dd><a href="javascript:;" onclick="openUrl('contentList.html')">公告查询</a></dd>
            <dd><a href="javascript:;" onclick="openUrl('contentAdd.html')">公告发布</a></dd>
            <!--            <dd><a href="">超链接</a></dd>-->
          </dl>
        </li>
      </ul>
    </div>
  </div>

  <div class="layui-body" id = "center">
    <!-- 内容主体区域 -->
    <div style="padding: 15px;">
      <h1>欢迎来到鲜花订购后台</h1>
    </div>
  </div>

<!--  <div class="layui-footer">-->
<!--    &lt;!&ndash; 底部固定区域 &ndash;&gt;-->
<!--    底部固定区域-->
<!--  </div>-->
</div>
<script src="layui/layui.js"></script>
<script>
  //JS
  layui.use(['element', 'layer', 'util'], function(){
    var element = layui.element
            ,layer = layui.layer
            ,util = layui.util
            ,$ = layui.$;

    //头部事件
    util.event('lay-header-event', {
      //左侧菜单事件
      menuLeft: function(othis){
        layer.msg('展开左侧菜单的操作', {icon: 0});
      }
      ,menuRight: function(){
        layer.open({
          type: 1
          ,content: '<div style="padding: 15px;">处理右侧面板的操作</div>'
          ,area: ['260px', '100%']
          ,offset: 'rt' //右上角
          ,anim: 5
          ,shadeClose: true
        });
      }
    });

  });
</script>
</body>

<script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-3.5.1.min.js"></script>
<script type="application/javascript">
  function openUrl(url){
    // alert(url);
    $("#center").load(url);
  }
</script>

<script>
    var jsonAdmin = localStorage.getItem("admin");//获取数据
    var admin = JSON.parse(jsonAdmin);//类型转换
    $("#span").html(admin.username);//显示数据
</script>

<script>
  function queryAdmin(){
    var jsonAdmin = localStorage.getItem("admin");//获取数据
    var admin = JSON.parse(jsonAdmin);//类型转换
    var data = admin

    layer.open({
      type:1,
      content: $("#updateAdminForm").html(),
      title: ['个人信息', 'font-size:18px;'],
      area: ['600px', '600px'],
      success: function(){
        $("#id").val(data.id);
        $("#username").val(data.username);
        $("#password").val(data.password);
        $("#email").val(data.email);
        $("#cellphone").val(data.cellphone);
        $("#createTime").val(layui.util.toDateString(data.createTime,'yyyy-MM-dd'));
        //渲染页面
        layui.form.render();
      },
      btn: ['提交', '取消']
      ,yes: function(index, layero){
        //修改操作
        $.get("/user/updateUser", $("#updateAdmin").serialize(),
                function(data){
                  if("success" == data){
                    // 退出登录
                    $.get("/user/logout")
                    layer.msg('修改成功',{
                      time:1000
                    }, function () {
                      //跳转到登录页面
                      // window.location = '/login.html';
                      location.reload();//刷新当前页面

                    });
                  }
                });
      }
      ,btn2: function(index, layero){
        alert("取消")
      }
    });
  }
</script>

<script type="text/html" id="updateAdminForm">
  <form class="layui-form" id="updateAdmin">
    <!-- 把id 作为隐藏域传过去 -->
    <input type="hidden" name="id" id="id">
    <div class="layui-form-item">
      <label class="layui-form-label">账号</label>
      <div class="layui-input-inline">
        <input type="text" name="username" id="username" required  lay-verify="required" placeholder="请输入账号" autocomplete="off" class="layui-input">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">密码</label>
      <div class="layui-input-inline">
        <input type="text" name="password" id="password" required  lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">邮箱</label>
      <div class="layui-input-inline">
        <input type="text" name="email" id="email" required  lay-verify="required" placeholder="请输入邮箱" autocomplete="off" class="layui-input">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">手机号</label>
      <div class="layui-input-inline">
        <input type="text" name="cellphone" id="cellphone" required  lay-verify="required" placeholder="请输入手机号" autocomplete="off" class="layui-input">
      </div>
    </div>

    <div class="layui-form-item">
      <label class="layui-form-label">是否管理员</label>
      <div class="layui-input-inline">
        <select name="flag" id="flag" lay-verify="required">
          <option value="1">是</option>
          <option value="0">否</option>
        </select>
      </div>
    </div>
    <div class="layui-form-item">
      <div class="layui-inline">
        <label class="layui-form-label">注册时间</label>
        <div class="layui-input-inline">
          <input type="date" name="createTime" id="createTime" lay-verify="date" placeholder="注册时间" autocomplete="off" class="layui-input">
        </div>
      </div>
    </div>
  </form>
</script>

</html>